# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=pystring
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.1.3
pkgrel=1
pkgdesc="A collection of C++ functions which match the interface and behavior of python's string class methods using std::string (mingw-w64)"
arch=('any')
url="https://github.com/imageworks/pystring"
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('strip')
source=(${_realname}-${pkgver}.tar.gz::https://github.com/imageworks/pystring/archive/v${pkgver}.tar.gz
        01-makefile.patch)
sha256sums=('358a56e756e701836b69a31c75d3d9d41c34d447cf7b3775bbd5620dcd3203d9'
            '9f210c79dbe0a87832747379161944c45996bfcd5091ee8c91d4180e8d4bcdec')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/01-makefile.patch
}

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  cp -rf ${_realname}-${pkgver} build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}

  make
}

package() {
  mkdir -p ${pkgdir}${MINGW_PREFIX}/{include/pystring,lib}
  cd build-${MINGW_CHOST}
  make DESTDIR=${pkgdir} PREFIX=${MINGW_PREFIX} install
  install -Dm644 ${srcdir}/${_realname}-${pkgver}/LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
